package com.ruoyi.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.entity.po.TPlayer;
import com.ruoyi.mapper.TPlayerMapper;
import com.ruoyi.service.IPlayerService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chenhainan
 * @since 2024-12-08 17:31
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class PlayerServiceImpl implements IPlayerService {

    private final TPlayerMapper playerMapper;

    @Override
    public boolean addPlayer(TPlayer player) {
        return playerMapper.insertSelective(player) > 0;
    }

    @Override
    public boolean updatePlayer(TPlayer player) {
        return playerMapper.updateByPrimaryKeySelective(player) > 0;
    }

    @Override
    public boolean deletePlayerById(Integer id) {
        return playerMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public List<TPlayer> selectPlayerList(TPlayer tPlayer) {
        return playerMapper.selectTActivitySwitchList(tPlayer);
    }

    @Override
    public int deleteTActivitySwitchByIds(String ids) {
        return playerMapper.deleteTActivitySwitchByIds(Convert.toStrArray(ids));
    }

    @Override
    public int eliminatePlayer(Integer playerId) {
        return playerMapper.eliminatePlayer(playerId);
    }

    @Override
    public void updateCustomizeValue(String name, Double customizeValue) {
        playerMapper.updateCustomizeValue(name, customizeValue);
    }

    @Override
    public TPlayer selectByName(String playerName) {
        return playerMapper.selectByName(playerName);
    }


    @Override
    public TPlayer selectByPhoneNum(String phoneNum) {
        return playerMapper.selectByPhoneNum(phoneNum);
    }
}
